Various aspects of the present invention relate generally to garbage collection in virtual machines, and more specifically to the automated tuning of garbage collection processes in an environment supporting multiple virtual machines.
A virtual machine is a software representation of a physical machine that provides resources and abstractions to an application running within the virtual machine. To provide necessary resources, the virtual machine may reserve a single contiguous slot of memory, often referred to as a heap, from a host physical computer. The heap is used to temporarily store objects created by the application running on the virtual machine.
At certain times, such as when the heap is close to full, the associated virtual machine invokes a garbage collection (GC) process. The garbage collection process is typically broken down into multiple phases or operations. For instance, a basic garbage collection process initially identifies objects in an associated heap that are no longer being used. The garbage collection process then reclaims the memory within the heap that is occupied by the unused objects that were previously identified. For instance, the garbage collection process may de-allocate objects identified as being unused so that memory within the heap is freed up for future allocations.
However, in certain situations, a basic garbage collection process will not suffice. As such, the garbage collection process may also include an additional compaction phase. The compaction phase is utilized to defragment the allocated objects that were not previously reclaimed, so as to move allocated objects that are still being used into contiguous memory chunks within the heap.